<template>
  <div class="screen-container">
    <div class="screen-head">
      <div class="head-left">
      </div>
      <div class="head-middle">
        <div class="title">
          <div class="title_">
            诗词歌赋
          </div>
        </div>
        <div class="navigation">
          <router-link to="/" class="nav-button">
            <i class="el-icon-house"></i>
            返回首页
          </router-link>
        </div>
      </div>
    </div>
    <div class="screen-body">
      <div class="body-left">
        <div class="panel">
          <div class="panel-header">
            <h3>词云分析</h3>
            <div class="resize-button" @click="changeSize('cloud')">
              <i :class="isFullScreen.cloud ? 'el-icon-close' : 'el-icon-full-screen'"></i>
            </div>
          </div>
          <div class="panel-content" :class="{ 'full-screen': isFullScreen.cloud }">
            <poetry-cloud ref="cloud" />
          </div>
        </div>
        <div class="panel">
          <div class="panel-header">
            <h3>双音节词统计</h3>
            <div class="resize-button" @click="changeSize('words')">
              <i :class="isFullScreen.words ? 'el-icon-close' : 'el-icon-full-screen'"></i>
            </div>
          </div>
          <div class="panel-content" :class="{ 'full-screen': isFullScreen.words }">
            <poetry-words ref="words" />
          </div>
        </div>
      </div>
      <div class="body-right">
        <div class="panel">
          <div class="panel-header">
            <h3>诗人统计</h3>
            <div class="resize-button" @click="changeSize('stats')">
              <i :class="isFullScreen.stats ? 'el-icon-close' : 'el-icon-full-screen'"></i>
            </div>
          </div>
          <div class="panel-content" :class="{ 'full-screen': isFullScreen.stats }">
            <poet-stats ref="stats" />
          </div>
        </div>
      </div>
      <div class="body-bottom">
        <div class="panel">
          <div class="panel-header">
            <h3>诗词名句</h3>
            <div class="resize-button" @click="changeSize('quotes')">
              <i :class="isFullScreen.quotes ? 'el-icon-close' : 'el-icon-full-screen'"></i>
            </div>
          </div>
          <div class="panel-content" :class="{ 'full-screen': isFullScreen.quotes }">
            <poetry-quotes ref="quotes" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import PoetryCloud from '@/components/poetry/PoetryCloud'
import PoetStats from '@/components/poetry/PoetStats'
import PoetryWords from '@/components/poetry/PoetryWords'
import PoetryQuotes from '@/components/poetry/PoetryQuotes'

export default {
  name: 'ScreenPage3',
  components: {
    PoetryCloud,
    PoetStats,
    PoetryWords,
    PoetryQuotes
  },
  data() {
    return {
      isFullScreen: {
        cloud: false,
        stats: false,
        words: false,
        quotes: false
      }
    }
  },
  methods: {
    changeSize(component) {
      this.isFullScreen[component] = !this.isFullScreen[component]
      this.$nextTick(() => {
        const ref = this.$refs[component]
        if (ref && typeof ref.updateChart === 'function') {
          ref.updateChart()
        }
      })
    }
  }
}
</script>

<style scoped>
.screen-container {
  width: 100%;
  height: 100vh;
  min-height: 900px;
  background: url('/static/img/bc-p3.jpg') no-repeat center center;
  background-size: cover;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.screen-head {
  height: 80px;
  min-height: 80px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  background: linear-gradient(to right, rgba(255, 123, 0, 0.8), rgba(255, 158, 69, 0.8));
  border-bottom: 2px solid #ff7b00;
  position: sticky;
  top: 0;
  z-index: 10;
}

.head-left {
  width: 150px;
}

.head-middle {
  flex: 1;
  text-align: center;
}

.title_ {
  font-size: 28px;
  color: #fff;
  font-family: "楷体", serif;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.navigation {
  margin-top: 10px;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: rgba(255, 123, 0, 0.2);
  border-radius: 4px;
  color: #fff;
  text-decoration: none;
  transition: all 0.3s ease;
}

.nav-button:hover {
  background: rgba(255, 123, 0, 0.4);
  transform: translateY(-2px);
}

.screen-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(700px, 1fr) 180px;
  gap: 20px;
  padding: 20px;
  overflow: visible;
  height: calc(100vh - 80px);
  min-height: 900px;
}

.body-left {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
}

.body-right {
  grid-column: 2;
  grid-row: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.body-right .panel {
  flex: 1;
  min-height: 700px;
}

.body-left .panel {
  height: calc(50% - 10px);
  min-height: 340px;
  display: flex;
  flex-direction: column;
}

.body-bottom {
  grid-column: 1 / span 2;
  grid-row: 2;
}

.panel {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 123, 0, 0.3);
}

.panel-header {
  padding: 15px;
  background: rgba(255, 123, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 123, 0, 0.2);
  flex-shrink: 0;
}

.panel-header h3 {
  margin: 0;
  color: #ff7b00;
  font-family: "楷体", serif;
  font-size: 18px;
}

.resize-button {
  cursor: pointer;
  color: #ff7b00;
}

.panel-content {
  flex: 1;
  padding: 15px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-content > div {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.panel-content.full-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: #fff;
  padding: 20px;
}

.panel-content.full-screen > div {
  height: 100%;
  width: 100%;
}
</style>